package com.atguigu.lease.common.context;
/*
*  在本地线程中维护loginUser(登录用户)的数据
* */
public class LoginUserContext {
    private static final ThreadLocal<LoginUser> threadLocal=new ThreadLocal<>();
      //把登录的用户信息保存到threadLocal中
    public static void setUser(LoginUser loginUser){
        threadLocal.set(loginUser);
    }


      //从threadLocal中获取登录的用户信息
      public static LoginUser getUser(){
          LoginUser loginUser = threadLocal.get();
          return loginUser;
      }
      //从threadLocal中删除登录的用户信息

    public static void removeUser(){
        threadLocal.remove();
    }


}
